package Screens;

import Utils.SoundManager;
import Utils.TextWrapper;

import com.badlogic.gdx.Screen;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input.Buttons;
import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.audio.Sound;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.Texture.TextureFilter;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Vector2;
import com.acumenvn.pent.MyPent;

public class GameOverScreen implements Screen {
	TextWrapper mText;
	Texture mTexture;
	SpriteBatch mBatch;
	MyPent mGame;
	float timeToLoad;
	Sound mClickSound;
	
	public GameOverScreen(MyPent game) {
		// TODO Auto-generated constructor stub
		this.mGame = game;
	} 
	
	@Override
	public void render(float delta) {
		// TODO Auto-generated method stub
		Gdx.gl20.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
		if(Gdx.input.isKeyPressed(Keys.ENTER)) {
			mClickSound.play();
			mGame.setScreen(new MainMenuScreen(mGame));
		}
		mBatch.begin();
		mBatch.draw(mTexture, 0, 0);
		mText.Draw(mBatch, new BitmapFont(Gdx.files.internal("Fonts/myFont.fnt"), false));
		mBatch.end();
//		if(timeToLoad > 0) {
//			timeToLoad -= delta;
//			return;
//		}
//		mGame.setScreen(new MainMenuScreen(mGame));
	}

	@Override
	public void resize(int width, int height) {
		// TODO Auto-generated method stub
	}

	@Override
	public void show() {
		// TODO Auto-generated method stub
		timeToLoad = 1;
		mTexture = new Texture(Gdx.files.internal("Images/Gameover.png"));
		mTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
		mBatch = new SpriteBatch();
		Gdx.graphics.setContinuousRendering(false);
		Gdx.graphics.requestRendering();
		float h = Gdx.graphics.getHeight();
		float w = Gdx.graphics.getWidth();
		mText = new TextWrapper("Press ENTER to continue", new Vector2(w/2, h/2 - 100));
		mClickSound = SoundManager.getInstance().getSoundSelectMenu();
	}

	@Override
	public void hide() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void pause() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void resume() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void dispose() {
		// TODO Auto-generated method stub
		mTexture.dispose();
		
	}

}
